package com.dense.kuiniu.bookborrow.view.alpha;

import android.content.Context;
import android.util.AttributeSet;

import com.dense.kuiniu.bookborrow.view.alpha.helper.AlphaViewHelper;

import androidx.appcompat.widget.AppCompatTextView;

/**
 * @author zhangyu
 * @date 2020/5/5
 */
public class AlphaTextView extends AppCompatTextView {
    private AlphaViewHelper mAlphaViewHelper;

    public AlphaTextView(Context context) {
        super(context);
    }

    public AlphaTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public AlphaTextView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    private AlphaViewHelper getAlphaViewHelper() {
        if (mAlphaViewHelper == null) {
            mAlphaViewHelper = new AlphaViewHelper(this);
        }
        return mAlphaViewHelper;
    }

    @Override
    public void setPressed(boolean pressed) {
        super.setPressed(pressed);
        getAlphaViewHelper().onPressedChanged(this, pressed);
    }

    @Override
    public void setEnabled(boolean enabled) {
        super.setEnabled(enabled);
        getAlphaViewHelper().onEnabledChanged(this, enabled);
    }
}
